
package org.xilin

class Family implements Serializable {
    String userId
    String fatherFirstName
    String fatherLastName
    String motherFirstName
    String motherLastName
    String fatherChineseName
    String motherChineseName
    String address
    String city
    String state
    String zipCode
    String homeTel_1
    String homeTel_2
    String homeTel_3
    String workTel_1
    String workTel_2
    String workTel_3
    String workTel_ext
//    String email
    
//    static transients = ['email']
    static mapping = {
//        cache:false
        students lazy:false
        version: false
    }
    
    static constraints = {
        userId(blank: false, unique: true)
        fatherFirstName(blank: false)
        fatherLastName(blank: false)
        motherFirstName(blank: false)
        motherLastName(blank: false)
        address(blank: false)
        city(blank: false)
        state(blank: false)
        zipCode(blank: false)
        homeTel_1(blank: false)
        homeTel_2(blank: false)
        homeTel_3(blank: false)
        workTel_1(nullable: true)
        workTel_2(nullable: true)
        workTel_3(nullable: true)
        workTel_ext(nullable: true)
    }
    
    static hasMany = [students : Student]

    String toString() {
        if (fatherFirstName) {
            fatherFirstName + " " + fatherLastName
        }
        else {
            motherFirstName + " " + motherLastName
        }
    }

}
